package com.tw.battle;

import java.util.HashMap;
import java.util.Random;

import com.tw.playerdata.Player;

public class Battle 
{
	Player p = new Player(true,8);
	Player e = null;
	
	int score = 8;
	
	HashMap<String,String> playerbattlestats;
	HashMap<String,String> enemybattlestats;
	
	public Battle()
	{
		playerbattlestats = p.startBattle();
		System.out.println("Player:");
		p.printStats();
		e = new Player(score);
		enemybattlestats = e.startBattle();
		System.out.println("First Enemy:");
		e.printStats();
	}
	
	public void step()
	{
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		enemybattlestats.put("currenthp",new Double(Double.parseDouble(enemybattlestats.get("currenthp")) - Double.parseDouble(playerbattlestats.get("dmg"))).toString());
		playerbattlestats.put("currenthp",new Double(Double.parseDouble(playerbattlestats.get("currenthp")) - Double.parseDouble(enemybattlestats.get("dmg"))).toString());
		
		System.out.println("enemyhp: " + enemybattlestats.get("currenthp"));
		System.out.println("playerhp: " + playerbattlestats.get("currenthp"));
		System.out.println();
		if(Double.parseDouble(playerbattlestats.get("currenthp")) <= 0 )
		{
			System.out.println("Player is dead, score: " + p.getCurrency());
			return;
		}
		if(Double.parseDouble(enemybattlestats.get("currenthp")) <= 0 )
		{
			p.giveCurrency(1+10/score);
			score += score/8;
			e = new Player(score);
			enemybattlestats = e.startBattle();
			System.out.println("New Enemy (score="+score+"):");
			e.printStats();
		}
	}
}
